<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"
    import="java.io.PrintWriter, java.util.Calendar, 
    		cn.edu.nju.software.model.administrator.MemberManager" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%
	String administratorName = (String) application.getAttribute("administratorName");
	if (administratorName == null || administratorName.equals("")) {
		PrintWriter printWriter = response.getWriter();
		printWriter.println("<script>alert('Please login first!');" + 
							"window.location.href='index.jsp';</script>");
	}
%>

<html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<link type="text/css" rel="stylesheet" href="../css/administrator/member.css" />
	<link type="text/css" rel="stylesheet" href="../css/administrator/menu.css" />
	<link type="text/css" rel="stylesheet" href="../css/administrator/footer.css" />
	<title>会员管理</title>
</head>

<body>
	<div id="menu">
		<a href="administrator.jsp"><img src="../images/administrator/menu/menu_homepage.png" alt="首页" /></a>
		<a href="member.jsp"><img src="../images/administrator/menu/menu_member.png" alt="会员管理" /></a>
		<a href="display.jsp"><img src="../images/administrator/menu/menu_display.png" alt="放映管理" /></a>
		<a href="ticket.jsp"><img src="../images/administrator/menu/menu_ticket.png" alt="售票" /></a>
		<a href="statistics.jsp"><img src="../images/administrator/menu/menu_statistics.png" alt="统计分析" /></a>
		<a href="information.jsp"><img src="../images/administrator/menu/menu_information.png" alt="信息" /></a>
		<a href="index.jsp"><img src="../images/administrator/menu/menu_logout.png" alt="注销" /></a>
	</div>
	
	<div id="content">
	
		<div id="member_register">
			<div class="cell_title">会员注册</div>
			<form method="post" action="../MemberRegister.do">
				<table>
					<tr class="color_row">
						<td>用户名</td>
						<td><input type=text" name="username" value="" /></td>
					</tr>
					<tr>
						<td>密码</td>
						<td><input type="password" name="password" value="" /></td>
					</tr>
					<tr class="color_row">
						<td>会员级别</td>
						<td>
							<input type="radio" name="level_id" value="0" />一般会员<br />
							<input type="radio" name="level_id" value="1" checked="checked" />初级会员<br />
							<input type="radio" name="level_id" value="2" />中级会员<br />
							<input type="radio" name="level_id" value="3" />高级会员<br />
						</td>
					</tr>
					<tr>
						<td>有效期</td>
						<td>
							<select name="year">
								<%
								int y = Calendar.getInstance().get(Calendar.YEAR);
								for (int i = 1; i <= 10; i++) {
									String year = "" + (i + y);
									%>
									<option value=<%= year %>><%= year %></option>
									<%
								}
								%>
							</select>&nbsp;年&nbsp;
							<select name="month">
								<%
								for (int i = 1; i <= 12; i++) {
									String month = "" + i;
									%>
									<option value=<%= month %>><%= month %></option>
									<%
								}
								%>
							</select>&nbsp;月&nbsp;
						</td>
					</tr>
					<tr class="color_row">
						<td>余额</td>
						<td><input type="text" name="balance" value="200" /></td>
					</tr>
					<tr>
						<td>性别</td>
						<td>
							<input type="radio" name="gender" value="male" checked="checked" />&nbsp;男&nbsp;
							<input type="radio" name="gender" value="female" />&nbsp;女&nbsp;
						</td>
					</tr>
					<tr class="color_row">
						<td>年龄</td>
						<td>
							<input type="radio" name="age" value="50" />&nbsp;50后&nbsp;
							<input type="radio" name="age" value="60" />&nbsp;60后&nbsp;
							<input type="radio" name="age" value="70" />&nbsp;70后&nbsp;<br />
							<input type="radio" name="age" value="80" checked="checked" />&nbsp;80后&nbsp;
							<input type="radio" name="age" value="90" />&nbsp;90后&nbsp;
							<input type="radio" name="age" value="00" />&nbsp;00后&nbsp;
						</td>
					</tr>
					<tr>
						<td>爱看的电影类型</td>
						<td>
							<select name="type">
							<option value="comedy">喜剧片</option>
							<option value="action">动作片</option>
							<option value="love">爱情片</option>
							<option value="science">科幻片</option>
							<option value="war">战争片</option>
							<option value="adventure">冒险片</option>
							<option value="terror">恐怖片</option>
							<option value="animation">动画片</option>
							<option value="literature">文艺片</option>
							</select>
						</td>
					</tr>
					<tr class="color_row">
						<td></td>
						<td>
							<input type="submit" value="注册" />
							<input type="reset" value="重新填写" />
						</td>
					</tr>
				</table>
			</form>
		</div>
		
		<div id="member_manage">
			<div class="cell_title">会员管理</div>
			<form method="post" action="../MemberAlter.do">
				<table>
					<tr class="color_row">
						<td>选择会员</td>
						<td>
							<select name="username">
								<%
								MemberManager memberManager = new MemberManager();
								String[] members = memberManager.fetchAllMembers();
								for (int i = 0; i < members.length; i++) {
									String name = members[i];
									%>
									<option value<%= name %>><%= name %></option>
									<%
								}
								%>
							</select>
						</td>
					</tr>
					<tr>
						<td>管理操作</td>
						<td>
							<input type="radio" name="level_id" value="0" />一般会员<br />
							<input type="radio" name="level_id" value="1" checked="checked" />初级会员<br />
							<input type="radio" name="level_id" value="2" />中级会员<br />
							<input type="radio" name="level_id" value="3" />高级会员<br />
						</td>
					</tr>
					<tr class="color_row">
						<td>有效期</td>
						<td>
							<select name="year">
								<%
								for (int i = 1; i <= 10; i++) {
									String year = "" + (i + y);
									%>
									<option value=<%= year %>><%= year %></option>
									<%
								}
								%>
							</select>&nbsp;年&nbsp;
							<select name="month">
								<%
								for (int i = 1; i <= 12; i++) {
									String month = "" + i;
									%>
									<option value=<%= month %>><%= month %></option>
									<%
								}
								%>
							</select>&nbsp;月&nbsp;
						</td>
					</tr>
					<tr>
						<td>余额</td>
						<td><input type="text" name="balance" value="200" /></td>
					</tr>
					<tr class="color_row">
						<td></td>
						<td>
							<input type="submit" value="确定" />
							<input type="reset" value="重新填写" />
						</td>
					</tr>
				</table>
			</form>
		</div>
		
	</div>
	
	<div id="footer">
		<p>
			Copyright &copy; <a href="mailto:zyy08@software.nju.edu.cn">张迎亚</a>·南京大学·软件学院·2011春节
		</p>
	</div>
	
</body>

</html>